package cn.lds.j375.chlm.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class ResultDTO<T> {

    private Integer code;

    private String msg;

    private T obj;

    public static ResultDTO buildSuccess(){
        return new ResultDTO(ResultEnum.SUCCESS.getCode(),ResultEnum.SUCCESS.getMsg(), null);
    }

    public static ResultDTO buildSuccess(Object obj){
        return new ResultDTO(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), obj);
    }

    public static ResultDTO buildError(){
        return new ResultDTO(ResultEnum.ERROR.getCode(),ResultEnum.ERROR.getMsg(), null);
    }
    public static ResultDTO buildError(String msg){
        return new ResultDTO(ResultEnum.ERROR.getCode(), msg,null);
    }
}
